// 20210629
// 参考了LeetCode CookBook的写法，主要是不知道怎么用Go写字符串加数字
// LeetCode CookBook项目地址：https://github.com/halfrost/LeetCode-Go.git

package leetcode

func convertToTitle(columnNumber int) string {
	res := []byte{}

	for columnNumber > 0 {
		mod := (columnNumber - 1) % 26
		columnNumber = (columnNumber - 1) / 26
		res = append(res, 'A' + byte(mod))
	}

	for i, j := 0, len(res) - 1; i < j; i, j = i + 1, j - 1 {
		res[i], res[j] = res[j], res[i]
	}

	return string(res)
}


